from flask import Blueprint, request, session
from src.api.https import SUCCESS, FAIL

from src.api.https import fail_api, success_api
from src.model.CLikeModel import CLikeModel
from src.model.CommentModel import CommentModel
from src.utils.check_require import login_required

from src.init.init_db import db
from src.utils.test_tool import TestTool

test_api = Blueprint('test_api', __name__, url_prefix='/api/test')

ttool = TestTool()


@test_api.get('/clearuser')
def clearUser():
    if ttool.clear_user_info() == SUCCESS:
        return success_api(msg="清除用户成功")
    else:
        return fail_api(msg="清除用户失败，可能是用户有文章发布，请先清除所有文章")


@test_api.get('/cleararticle')
def clearArticle():
    if ttool.clear_article_info() == SUCCESS:
        return success_api(msg="清除文章成功")
    else:
        return fail_api(msg="清除文章失败")


@test_api.get('/user')
def initUser():
    if ttool.init_user_info() == SUCCESS:
        return success_api(msg="装填用户成功")
    else:
        return fail_api(msg="装填用户失败，可能是已有用户，请先清除所有用户")


@test_api.get('/article')
def initArticle():
    if ttool.init_article_info() == SUCCESS:
        return success_api(msg="装填文章成功")
    else:
        return fail_api(msg="装填文章失败")
